package com.threadpool.juc;

import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;

/**
 * 通过execute提交的任务
 *
 * 区别于test2中submit提交任务
 *
 * @author: chenhs
 * @date: Created in 11:23 2019/8/30
 **/
public class TestThreadPool {
    public static void main(String[] args) {
        //创建线程池对象，控制要创建几个线程对象
        ExecutorService pool = Executors.newFixedThreadPool(2);

        //可以执行Runnable对象或者Callable对象代表的线程
        pool.execute(new MyRunnable());
        pool.execute(new MyRunnable());

        //结束线程池
        pool.shutdown();
    }
}
